home *** CD-ROM | disk | FTP | other *** search
/ STraTOS 1997 April & May / STraTOS 1 - 1997 April & May.iso / CD01 / INTERNET / SITES / LITTLE / A3DEV.ZIP / TARGA.S < prev   
Encoding:
Text File  |  1996-11-23  |  16.5 KB  |  749 lines

  1. *-------------------------------------------------------*
  2.             text
  3. *-------------------------------------------------------*
  4.  
  5. *-------------------------------------------------------*
  6.     OPT        O+,W+
  7. *-------------------------------------------------------*
  8.     include        ..\winsys\macros.s
  9.     include        ..\winsys\general.s
  10. *-------------------------------------------------------*
  11.     include        afd.inc
  12. *-------------------------------------------------------*
  13.  
  14. *-------------------------------------------------------*
  15.             rsreset
  16. *-------------------------------------------------------*
  17. targa_            rs.b    12
  18. targa_width        rs.w    1
  19. targa_height        rs.w    1
  20. targa_slen        rs.b    0
  21. *-------------------------------------------------------*
  22.  
  23. tga_id_len        =    0
  24. tga_cmap_type        =    1
  25. tga_image_type        =    2
  26. tga_cmap_origin        =    3
  27. tga_cmap_length        =    5
  28. tga_cmap_bits        =    7
  29. tga_xpos        =    8
  30. tga_ypos        =    10
  31.  
  32. tga_width        =    12
  33. tga_height        =    14
  34.  
  35. tga_pixsize        =    16
  36. tga_imgdesc        =    17
  37. tga_datastart        =    18
  38.  
  39. *-------------------------------------------------------*
  40. initialise_afd:
  41. *-------------------------------------------------------*
  42. *    Read inputs                    *
  43. *-------------------------------------------------------*
  44.     push.w        #2001
  45.     trap        #3
  46.     addq.l        #2,sp
  47.     move.l        d0,a0
  48.     move.l        a0,struct_ptr
  49.     move.l        afd_malloc(a0),malloc_ptr
  50.     move.l        afd_dealloc(a0),dealloc_ptr
  51.     move.l        afd_salloc(a0),salloc_ptr
  52.     move.l        afd_thread(a0),thread_ptr
  53.     move.l        afd_open(a0),open_ptr
  54.     move.l        afd_close(a0),close_ptr
  55.     move.l        afd_create(a0),create_ptr
  56.     move.l        afd_read(a0),read_ptr
  57.     move.l        afd_write(a0),write_ptr
  58.     move.l        afd_seek(a0),seek_ptr
  59.     move.l        afd_examine(a0),examine_ptr
  60.     move.l        afd_patch(a0),patch_ptr
  61. *-------------------------------------------------------*
  62. *    Write outputs                    *
  63. *-------------------------------------------------------*
  64.     move.l        #fext_targa,afd_extension(a0)
  65.     move.l        #finq_rout,afd_inquire(a0)
  66.     move.l        #fdec_rout,afd_decode(a0)
  67.     move.l        #fenc_rout,afd_encode(a0)
  68.     move.w        fcol_targa,afd_colour(a0)
  69.     move.w        #0,afd_id(a0)
  70.     rts
  71.  
  72. *-------------------------------------------------------*
  73. finq_rout:
  74. *-------------------------------------------------------*
  75.     move.w        #none,file_handle
  76.     move.l        struct_ptr,a6
  77.     lea        afd_filename(a6),a0
  78.     moveq        #0,d0
  79.     jsr        ([open_ptr.l])
  80.     tst.l        d0
  81.     bmi.s        .error
  82.     move.w        d0,file_handle
  83. *-------------------------------------------------------*
  84.     moveq        #targa_slen,d1
  85.     move.l        struct_ptr,a6
  86.     lea        afd_gpbuffer(a6),a0
  87.     jsr        ([read_ptr.l])
  88.     tst.l        d0
  89.     bmi.s        .error
  90. *-------------------------------------------------------*
  91.     move.l        struct_ptr,a6
  92.     lea        afd_gpbuffer(a6),a0
  93.     move.w        targa_width(a0),d1
  94.     move.w        targa_height(a0),d2
  95.     ror.w        #8,d1
  96.     ror.w        #8,d2
  97.     cmp.w        #5120,d1
  98.     bhi.s        .error
  99.     cmp.w        #5120,d2
  100.     bhi.s        .error
  101.     move.l        struct_ptr,a6
  102.     move.w        d1,afd_width(a6)
  103.     move.w        d2,afd_height(a6)
  104. *-------------------------------------------------------*
  105. .done:    moveq        #0,d0
  106.     bra.s        .exit
  107. *-------------------------------------------------------*
  108. .error:    move.l        struct_ptr,a6
  109.     clr.w        afd_width(a6)
  110.     clr.w        afd_height(a6)
  111.     moveq        #-1,d0
  112. *-------------------------------------------------------*
  113. .exit:    push.l        d0
  114.     move.w        file_handle,d0
  115.     jsr        ([close_ptr.l])
  116.     pop.l        d0
  117.     rts
  118.  
  119. *-------------------------------------------------------*
  120. fenc_rout:
  121. *-------------------------------------------------------*
  122.     rts
  123.  
  124. *-------------------------------------------------------*
  125. fdec_rout:
  126. *-------------------------------------------------------*
  127.     clr.w        pak_state
  128. *-------------------------------------------------------*
  129.     move.l        struct_ptr,a6
  130.     move.l        afd_imageptr(a6),targa_buffer
  131. *-------------------------------------------------------*
  132.     move.l        #12*1000,d0
  133.     move.l        d0,file_buffersize
  134.     moveq        #VRAM_preferred,d1
  135.     jsr        ([salloc_ptr.l])
  136.     tst.l        d0
  137.     ble.s        .err
  138.     move.l        d0,file_buffer
  139. *-------------------------------------------------------*
  140.     move.w        #none,file_handle
  141.     move.l        struct_ptr,a6
  142.     lea        afd_filename(a6),a0
  143.     moveq        #0,d0
  144.     jsr        ([open_ptr.l])
  145.     tst.l        d0
  146.     bmi.s        .err
  147.     move.w        d0,file_handle
  148. *-------------------------------------------------------*
  149.     move.l        struct_ptr,a6
  150.     lea        afd_gpbuffer(a6),a0
  151.     moveq        #tga_datastart,d1
  152.     jsr        ([read_ptr.l])
  153.     tst.l        d0
  154.     bmi.s        .err
  155.     move.l        struct_ptr,a6
  156.     sub.l        d0,afd_filesize(a6)
  157. *-------------------------------------------------------*
  158.     move.l        struct_ptr,a6
  159.     lea        afd_gpbuffer(a6),a6
  160.     move.b        tga_image_type(a6),d0
  161.     move.b        d0,targa_type
  162.     cmp.b        #2,d0
  163.     beq.s        .decode_image
  164.     cmp.b        #10,d0
  165.     bne.s        .err
  166. *-------------------------------------------------------*
  167. .decode_image:
  168. *-------------------------------------------------------*
  169.     bsr        targa_true_colour
  170. *-------------------------------------------------------*
  171.     moveq        #0,d0
  172.     bra.s        .exit
  173. *-------------------------------------------------------*
  174. .err:    moveq        #-1,d0
  175. *-------------------------------------------------------*
  176. .exit:    push.l        d0
  177.     move.w        file_handle,d0
  178.     jsr        ([close_ptr.l])
  179.     pop.l        d0
  180.     rts
  181.     
  182. *-------------------------------------------------------*
  183. targa_true_colour:
  184. *-------------------------------------------------------*
  185.     move.l        struct_ptr,a6
  186.     move.w        afd_width(a6),d0
  187.     mulu.w        afd_height(a6),d0
  188.     move.l        d0,targa_pixels
  189. *-------------------------------------------------------*
  190.     move.l        struct_ptr,a6
  191.     lea        afd_gpbuffer(a6),a6
  192.     moveq        #0,d0
  193.     move.b        tga_pixsize(a6),d0
  194.     move.w        d0,file_cols
  195. *-------------------------------------------------------*
  196. *    Skip any header comments            *
  197. *-------------------------------------------------------*
  198.     move.b        tga_id_len(a6),d0
  199.     beq.s        .no_comments
  200.     pushall
  201.     ext.w        d0
  202.     ext.l        d0
  203.     move.l        d0,d1
  204.     move.l        struct_ptr,a6
  205.     sub.l        d1,afd_filesize(a6)
  206.     move.w        file_handle,d0
  207.     move.l        targa_buffer,a0
  208.     jsr        ([read_ptr.l])
  209.     popall
  210. *-------------------------------------------------------*
  211. .no_comments:
  212. *-------------------------------------------------------*
  213.     bsr        decrunch
  214.     moveq        #0,d0
  215. .err    rts
  216.  
  217. *-------------------------------------------------------*
  218. decrunch:
  219. *-------------------------------------------------------*
  220.     cmp.w        #24,file_cols
  221.     beq.s        .l24
  222.     cmp.w        #32,file_cols
  223.     beq.s        .l32
  224. .l16    moveq        #0,d0
  225.     bra.s        .go
  226. .l24    moveq        #1,d0
  227.     bra.s        .go
  228. .l32    moveq        #2,d0
  229. .go    add.w        d0,d0
  230.     cmp.b        #10,targa_type
  231.     bne.s        .get
  232.     addq        #1,d0
  233. .get    lea        decrunchers,a1
  234.     lsl.w        #2,d0
  235.     move.l        (a1,d0.w),loader
  236.     push.l        targa_buffer
  237. .loop    jsr        read_block
  238.     move.l        targa_buffer,a1
  239.     move.l        loader,a0    
  240.     jsr        (a0)
  241.     move.l        a1,targa_buffer
  242.     move.l        struct_ptr,a6
  243.     tst.l        afd_filesize(a6)
  244.     ble.s        .stop
  245.     tst.l        targa_pixels
  246.     bgt.s        .loop
  247. .stop    pop.l        targa_buffer
  248.     rts    
  249.     
  250. decrunchers:
  251.     dc.l        raw_16bit,pak_16bit
  252.     dc.l        raw_24bit,pak_24bit
  253.     dc.l        raw_32bit,pak_32bit
  254.     
  255. *-------------------------------------------------------*
  256. *    16-bit unpack routine                *
  257. *-------------------------------------------------------*
  258.     
  259. *-------------------------------------------------------*
  260.         rsreset
  261. *-------------------------------------------------------*
  262. p16_strt    rs.b    1
  263. p16_code    rs.b    1
  264. p16_gotrlu    rs.b    1
  265. p16_gotcpu    rs.b    1
  266. p16_gotcpl    rs.b    1
  267.  
  268. p16_routs:    dc.l    G16_strt
  269.         dc.l    G16_code
  270.         dc.l    G16_rlU
  271.         dc.l    G16_cpU
  272.         dc.l    G16_cpL
  273.  
  274. pak_16bit:
  275.     move.l        file_buffer,a0
  276.     move.w        pak_state,d0
  277.     lsl.w        #2,d0
  278.     lea        p16_routs,a2
  279.     move.l        (a2,d0.w),a2
  280.     jmp        (a2)
  281.  
  282. G16_strt:
  283.     moveq        #0,d7
  284.     move.b        (a0)+,d7
  285.     move.w        d7,got_code
  286.     move.w        #p16_code,pak_state
  287.     subq.l        #1,counter
  288.     beq        G16_stop
  289. G16_code:
  290.     move.w        got_code,d7
  291.     tst.b        d7
  292.     bmi        G16_run
  293. G16_copy:
  294.     and.w        #%1111111,d7
  295.     addq        #1,d7
  296.     move.w        d7,copysize
  297. G16_cpL:
  298.     move.w        #p16_gotcpu,pak_state
  299.     move.b        (a0)+,cpU
  300.     subq.l        #1,counter
  301.     beq        G16_stop
  302. G16_cpU:
  303.     move.w        #p16_gotcpl,pak_state
  304.     move.b        cpU,d0
  305.     ror.w        #8,d0
  306.     move.b        (a0)+,d0
  307.     ror.w        #8,d0
  308.     move.w        d0,d1
  309.     lsl.w        #3,d1
  310.     move.w        d0,d2
  311.     lsr.w        #2,d2
  312.     move.w        d0,d3
  313.     lsr.w        #7,d3
  314.     and.w        #%11111000,d1
  315.     and.w        #%11111000,d2
  316.     and.w        #%11111000,d3
  317.     move.b        d3,(a1)+
  318.     move.b        d2,(a1)+
  319.     move.b        d1,(a1)+
  320.     move.b        #0,(a1)+
  321.     subq.l        #1,targa_pixels
  322.     beq        G16_stop
  323.     subq        #1,copysize
  324.     subq.l        #1,counter
  325.     move.l        counter,d0
  326.     or.w        copysize,d0
  327.     tst.l        d0
  328.     beq        G16_end
  329.     tst.l        counter
  330.     beq        G16_stop
  331.     tst.w        copysize
  332.     bne        G16_cpL
  333.     bra        G16_strt
  334. G16_run:
  335.     and.w        #%1111111,d7
  336.     move.w        d7,runsize
  337.     move.w        #p16_gotrlu,pak_state
  338.     move.b        (a0)+,rlU
  339.     subq.l        #1,counter
  340.     beq        G16_stop
  341. G16_rlU:
  342.     move.w        runsize,d7
  343.     move.b        rlU,d0
  344.     ror.w        #8,d0
  345.     move.b        (a0)+,d0
  346.     subq.l        #1,counter
  347.     ror.w        #8,d0
  348.     move.w        d0,d1
  349.     lsl.w        #3,d1
  350.     move.w        d0,d2
  351.     lsr.w        #2,d2
  352.     move.w        d0,d3
  353.     lsr.w        #7,d3
  354.     and.w        #%11111000,d1
  355.     and.w        #%11111000,d2
  356.     and.w        #%11111000,d3
  357. .run    move.b        d3,(a1)+
  358.     move.b        d2,(a1)+
  359.     move.b        d1,(a1)+
  360.     move.b        #0,(a1)+
  361.     subq.l        #1,targa_pixels
  362.     beq        G16_stop
  363.     dbra        d7,.run
  364.     tst.l        counter
  365.     bne        G16_strt
  366. G16_end:
  367.     move.w        #p16_strt,pak_state
  368. G16_stop
  369.     rts
  370.  
  371.  
  372. *-------------------------------------------------------*
  373. *    24-bit unpack routine                *
  374. *-------------------------------------------------------*
  375.     
  376. *-------------------------------------------------------*
  377.         rsreset
  378. *-------------------------------------------------------*
  379. p24_strt    rs.b    1
  380. p24_code    rs.b    1
  381. p24_gotrlr    rs.b    1
  382. p24_gotrlg    rs.b    1
  383. p24_gotcpr    rs.b    1
  384. p24_gotcpg    rs.b    1
  385. p24_gotcpb    rs.b    1
  386.  
  387. p24_routs:    dc.l    G24_strt
  388.         dc.l    G24_code
  389.         dc.l    G24_rlR
  390.         dc.l    G24_rlG
  391.         dc.l    G24_cpR
  392.         dc.l    G24_cpG
  393.         dc.l    G24_cpB
  394.  
  395. pak_24bit:
  396.     move.l        file_buffer,a0
  397.     move.w        pak_state,d0
  398.     lsl.w        #2,d0
  399.     lea        p24_routs,a2
  400.     move.l        (a2,d0.w),a2
  401.     jmp        (a2)
  402.  
  403. G24_strt:
  404.     moveq        #0,d7
  405.     move.b        (a0)+,d7
  406.     move.w        d7,got_code
  407.     move.w        #p24_code,pak_state
  408.     subq.l        #1,counter
  409.     beq        G24_stop
  410. G24_code:
  411.     move.w        got_code,d7
  412.     tst.b        d7
  413.     bmi        G24_run
  414. G24_copy:
  415.     and.w        #%1111111,d7
  416.     addq        #1,d7
  417.     move.w        d7,copysize
  418. G24_cpB:
  419.     move.w        #p24_gotcpr,pak_state
  420.     move.b        (a0)+,2(a1)
  421.     subq.l        #1,counter
  422.     beq        G24_stop
  423. G24_cpR:
  424.     move.w        #p24_gotcpg,pak_state
  425.     move.b        (a0)+,1(a1)
  426.     subq.l        #1,counter
  427.     beq        G24_stop
  428. G24_cpG:
  429.     move.w        #p24_gotcpb,pak_state
  430.     move.b        (a0)+,0(a1)
  431.     move.b        #0,3(a1)
  432.     addq.l        #4,a1
  433.     subq.l        #1,targa_pixels
  434.     beq        G24_stop
  435.     subq        #1,copysize
  436.     subq.l        #1,counter
  437.     move.l        counter,d0
  438.     or.w        copysize,d0
  439.     tst.l        d0
  440.     beq        G24_end
  441.     tst.l        counter
  442.     beq        G24_stop
  443.     tst.w        copysize
  444.     bne        G24_cpB
  445.     bra        G24_strt
  446. G24_run:
  447.     and.w        #%1111111,d7
  448.     move.w        d7,runsize
  449.     move.w        #p24_gotrlr,pak_state
  450.     move.b        (a0)+,rlR
  451.     subq.l        #1,counter
  452.     beq        G24_stop
  453. G24_rlR:
  454.     move.w        runsize,d7
  455.     move.w        #p24_gotrlg,pak_state
  456.     move.b        (a0)+,rlG    
  457.     subq.l        #1,counter
  458.     beq        G24_stop
  459. G24_rlG:
  460.     move.w        runsize,d7
  461.     move.b        (a0)+,d3
  462.     subq.l        #1,counter
  463.     move.b        rlR,d1
  464.     move.b        rlG,d2
  465. .run    move.b        d3,(a1)+
  466.     move.b        d2,(a1)+
  467.     move.b        d1,(a1)+
  468.     move.b        #0,(a1)+
  469.     subq.l        #1,targa_pixels
  470.     beq        G24_stop
  471.     dbra        d7,.run
  472.     tst.l        counter
  473.     bne        G24_strt
  474. G24_end:
  475.     move.w        #p24_strt,pak_state
  476. G24_stop
  477.     rts
  478.  
  479. *-------------------------------------------------------*
  480. *    32-bit unpack routine                *
  481. *-------------------------------------------------------*
  482.     
  483. *-------------------------------------------------------*
  484.         rsreset
  485. *-------------------------------------------------------*
  486. p32_strt    rs.b    1
  487. p32_code    rs.b    1
  488. p32_gotrlr    rs.b    1
  489. p32_gotrlg    rs.b    1
  490. p32_gotrlb    rs.b    1
  491. p32_gotcpr    rs.b    1
  492. p32_gotcpg    rs.b    1
  493. p32_gotcpb    rs.b    1
  494. p32_gotcpx    rs.b    1
  495.  
  496. p32_routs:    dc.l    G32_strt
  497.         dc.l    G32_code
  498.         dc.l    G32_rlR
  499.         dc.l    G32_rlG
  500.         dc.l    G32_rlB
  501.         dc.l    G32_cpR
  502.         dc.l    G32_cpG
  503.         dc.l    G32_cpB
  504.         dc.l    G32_cpX
  505.  
  506. pak_32bit:
  507.     move.l        file_buffer,a0
  508.     move.w        pak_state,d0
  509.     lsl.w        #2,d0
  510.     lea        p32_routs,a2
  511.     move.l        (a2,d0.w),a2
  512.     jmp        (a2)
  513.  
  514. G32_strt:
  515.     moveq        #0,d7
  516.     move.b        (a0)+,d7
  517.     move.w        d7,got_code
  518.     move.w        #p32_code,pak_state
  519.     subq.l        #1,counter
  520.     beq        G32_stop
  521. G32_code:
  522.     move.w        got_code,d7
  523.     tst.b        d7
  524.     bmi        G32_run
  525. G32_copy:
  526.     and.w        #%1111111,d7
  527.     addq        #1,d7
  528.     move.w        d7,copysize
  529. G32_cpX:
  530.     move.w        #p32_gotcpr,pak_state
  531.     move.b        (a0)+,2(a1)
  532.     subq.l        #1,counter
  533.     beq        G32_stop
  534. G32_cpR:
  535.     move.w        #p32_gotcpg,pak_state
  536.     move.b        (a0)+,1(a1)
  537.     subq.l        #1,counter
  538.     beq        G32_stop
  539. G32_cpG:
  540.     move.w        #p32_gotcpb,pak_state
  541.     move.b        (a0)+,0(a1)
  542.     subq.l        #1,counter
  543.     beq        G32_stop
  544. G32_cpB:
  545.     move.w        #p32_gotcpx,pak_state
  546.     move.b        (a0)+,3(a1)
  547.     addq.l        #4,a1
  548.     subq.l        #1,targa_pixels
  549.     beq        G32_stop
  550.     subq        #1,copysize
  551.     subq.l        #1,counter
  552.     move.l        counter,d0
  553.     or.w        copysize,d0
  554.     tst.l        d0
  555.     beq        G32_end
  556.     tst.l        counter
  557.     beq        G32_stop
  558.     tst.w        copysize
  559.     bne        G32_cpX
  560.     bra        G32_strt
  561. G32_run:
  562.     and.w        #%1111111,d7
  563.     move.w        d7,runsize
  564.     move.w        #p32_gotrlr,pak_state
  565.     move.b        (a0)+,rlR
  566.     subq.l        #1,counter
  567.     beq        G32_stop
  568. G32_rlR:
  569.     move.w        runsize,d7
  570.     move.w        #p32_gotrlg,pak_state
  571.     move.b        (a0)+,rlG    
  572.     subq.l        #1,counter
  573.     beq        G32_stop
  574. G32_rlG:
  575.     move.w        runsize,d7
  576.     move.w        #p32_gotrlb,pak_state
  577.     move.b        (a0)+,rlB    
  578.     subq.l        #1,counter
  579.     beq        G32_stop
  580. G32_rlB:
  581.     move.w        runsize,d7
  582.     move.b        (a0)+,d0
  583.     subq.l        #1,counter
  584.     move.b        rlR,d1
  585.     move.b        rlG,d2
  586.     move.b        rlB,d3
  587. .run    move.b        d3,(a1)+
  588.     move.b        d2,(a1)+
  589.     move.b        d1,(a1)+
  590.     move.b        d0,(a1)+
  591.     subq.l        #1,targa_pixels
  592.     beq        G32_stop
  593.     dbra        d7,.run
  594.     tst.l        counter
  595.     bne        G32_strt
  596. G32_end:
  597.     move.w        #p32_strt,pak_state
  598. G32_stop
  599.     rts
  600.  
  601. *-------------------------------------------------------*
  602. *    raw routines                    *
  603. *-------------------------------------------------------*
  604.     
  605. raw_16bit:
  606.     move.l        file_buffer,a0
  607.     move.l        counter,d7
  608. .rdlp    move.w        (a0)+,d0
  609.     ror.w        #8,d0
  610.     move.w        d0,d1
  611.     lsl.w        #3,d1
  612.     move.w        d0,d2
  613.     lsr.w        #2,d2
  614.     move.w        d0,d3
  615.     lsr.w        #7,d3
  616.     and.w        #%11111000,d1
  617.     and.w        #%11111000,d2
  618.     and.w        #%11111000,d3
  619.     move.b        d3,(a1)+
  620.     move.b        d2,(a1)+
  621.     move.b        d1,(a1)+
  622.     move.b        #0,(a1)+
  623.     subq.l        #2,d7
  624.     bgt.s        .rdlp
  625.     rts
  626.  
  627. raw_24bit:
  628.     move.l        file_buffer,a0
  629.     move.l        counter,d7
  630. .rdlp    move.b        (a0)+,2(a1)
  631.     move.b        (a0)+,1(a1)
  632.     move.b        (a0)+,0(a1)
  633.     move.b        #0,3(a1)
  634.     addq.l        #4,a1
  635.     subq.l        #3,d7
  636.     bgt.s        .rdlp
  637.     rts
  638.  
  639. raw_32bit:
  640.     move.l        file_buffer,a0
  641.     move.l        counter,d7
  642. .rdlp    move.b        (a0)+,2(a1)
  643.     move.b        (a0)+,1(a1)
  644.     move.b        (a0)+,0(a1)
  645.     move.b        (a0)+,3(a1)
  646.     addq.l        #4,a1
  647.     subq.l        #4,d7
  648.     bgt.s        .rdlp
  649.     rts
  650.  
  651. *-------------------------------------------------------*
  652. *    Read next block of data from disk        *
  653. *-------------------------------------------------------*
  654. read_block:
  655. *-------------------------------------------------------*
  656.     move.l        struct_ptr,a6
  657.     move.l        afd_filesize(a6),d0
  658.     move.l        file_buffersize,d1
  659.     sub.l        d1,d0
  660.     bpl.s        .cont
  661.     moveq        #0,d0
  662.     move.l        afd_filesize(a6),d1
  663. .cont    move.l        d0,afd_filesize(a6)
  664.     move.l        d1,counter
  665.     move.w        file_handle,d0
  666.     move.l        file_buffer,a0
  667.     jsr        ([read_ptr.l])
  668.     jsr        ([thread_ptr.l])
  669.     rts
  670.  
  671. *-------------------------------------------------------*
  672.             data
  673. *-------------------------------------------------------*
  674.  
  675. fcol_targa:        rgbw    128,192,255
  676. fext_targa:        dc.b    'tga',0
  677.             even
  678.  
  679. *-------------------------------------------------------*
  680.             bss
  681. *-------------------------------------------------------*
  682.  
  683. *-------------------------------------------------------*
  684. struct_ptr        ds.l    1
  685. *-------------------------------------------------------*
  686. *    Memory/subsystem routines            *
  687. *-------------------------------------------------------*
  688. malloc_ptr        ds.l    1
  689. dealloc_ptr        ds.l    1
  690. salloc_ptr        ds.l    1
  691. thread_ptr        ds.l    1
  692. *-------------------------------------------------------*
  693. *    Filesystem routines                *
  694. *-------------------------------------------------------*
  695. open_ptr        ds.l    1
  696. close_ptr        ds.l    1
  697. create_ptr        ds.l    1
  698. read_ptr        ds.l    1
  699. write_ptr        ds.l    1
  700. seek_ptr        ds.l    1
  701. examine_ptr        ds.l    1
  702. patch_ptr        ds.l    1
  703. *-------------------------------------------------------*
  704. *    File structure                    *
  705. *-------------------------------------------------------*
  706. width_ptr        ds.l    1
  707. height_ptr        ds.l    1
  708. imageptr_ptr        ds.l    1
  709. filesize_ptr        ds.l    1
  710. filename_ptr        ds.l    1
  711. gpbuffer_ptr        ds.l    1
  712.  
  713. *-------------------------------------------------------*
  714. *    Local variables                    *
  715. *-------------------------------------------------------*
  716.  
  717. buffer_base:        ds.l    1
  718. file_buffer:        ds.l    1
  719. file_buffersize:    ds.l    1
  720. file_handle:        ds.w    1
  721. file_cols:        ds.w    1
  722. file_type:        ds.w    1
  723.  
  724. loader:            ds.l    1
  725. counter:        ds.l    1
  726. targa_pixels:        ds.l    1
  727. targa_buffer:        ds.l    1
  728.  
  729. runsize:        ds.w    1
  730. copysize:        ds.w    1
  731. got_code:        ds.w    1
  732. pak_state:        ds.w    1
  733. targa_type:        ds.w    1
  734.  
  735. rlR:            ds.b    1
  736. rlG:            ds.b    1
  737. rlB:            ds.b    1
  738. rlU:            ds.b    1
  739.  
  740. cpR:            ds.b    1
  741. cpG:            ds.b    1
  742. cpB:            ds.b    1
  743. cpU:            ds.b    1
  744.             even
  745.  
  746. *-------------------------------------------------------*
  747.             text
  748. *-------------------------------------------------------*
  749.